package com.behelpful.common.core.exceptions;

import com.behelpful.common.core.result.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常拦截处理器
 *
 * @author Alay
 * @date 22021-08-04 23:58
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(IRuntimeException.class)
    public R captureParamException(IRuntimeException exception) {
        log.error(">>>> 参数错误 !!! , code ：{} ,message: {}<<<<", exception.getCode(), exception.getMessage());
        return R.failed(exception.getCode(), exception.getMessage());
    }
}
